<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        body{
            height: 2000px;
        }
        header{
            width: 100%;
            height: 55px;
            background: paleturquoise;
        }
        nav{
            width: 100%;
            height: 45px;
            background: papayawhip;
        }
        #search{
            width: 100%;
            height: 80px;
            background: pink;
        }
        .search_box{
            width: 350px;
            height: 30px;
            padding-top: 25px;
            margin: 0 auto;
            
        }
        #txt{
            width: 292px;
            height: 30px;
            padding-left: 8px;
            border:none;
            border-color: #ccc; 
            float: left;
            outline: none
        }
        #btn{
            width: 50px;
            height: 30px;
            border: none;
            color: #fff;
            background: #ccc;
            float: left;
        }
    </style>
</head>
<body>
    <header></header>
    <nav></nav>
    <div id="search">
        <div class="search_box">
            <input type="text" id="txt" placeholder="请输入内容....">
            <input type="button" value="搜索" id="btn">
        </div>
    </div>
</body>
<script>
    window.onscroll = function(){
        if(window.scrollY >= 100){
            search.style.position = "sticky";
            search.style.top = 0
        }
    }
</script>
</html>